<?php
/**
 * PushController.php class file.
 * @author wudg <544038230@qq.com>
 * @date 2020/12/31- 下午3:08
 */

namespace console\controllers;


use console\components\daemons\push\Daemon;
use console\components\daemons\push\Worker;
use yii\console\Controller;
use yii\console\ExitCode;

/**
 * 搬家上货队列消费
 * Class PushController
 * @package console\controllers
 */
class PushController extends Controller
{

    /**
     * 是否为守护进程模式运行
     * @var bool
     */
    public $daemon = false;

    /**
     * 启动服务
     * @return int
     */
    public function actionStart()
    {


        $worker = (new Worker())->run();
        return ExitCode::UNSPECIFIED_ERROR;
    }


    public function options($actionID)
    {
        return array_merge(parent::options($actionID), ['daemon']);
    }


    /**
     * 关闭服务
     * @return int
     */
    public function actionStop()
    {
        Daemon::stop();

        return ExitCode::OK;
    }

}